﻿Shader "Custom/CrystalReflect" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}

		_IllumMap ("Base (RGB)", 2D) = "white" {}

		_UVAnimX ("UV Anim X", float) = 0
		_UVAnimY ("UV Anim Y", float) = 0

		_Scale ("Scale", float) = 2

		_Mul ("Mul", float) = 1
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		Pass {
			LOD 200

			CGPROGRAM
			#pragma vertex vert 
	        #pragma fragment frag
	        #include "UnityCG.cginc"
			struct VertIn {
	        	float4 vertex : POSITION;
	        	float4 texcoord : TEXCOORD0;
	        };
	        
	        struct v2f {
	        	fixed4 pos : SV_POSITION;
	        	fixed2 uv : TEXCOORD0;
	        	fixed2 uv1 : TEXCOORD1;
	        };

	        uniform sampler2D _MainTex; 
	        uniform sampler2D _IllumMap; 
			uniform fixed _UVAnimX;
	        uniform fixed _UVAnimY;

	        uniform fixed _Scale;
	        uniform fixed _Mul;
	         
	        v2f vert(VertIn v) 
			{
				v2f o;
				o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

				o.uv = v.texcoord;

				float t1 = _Time.y*_UVAnimX;
				float t2 = _Time.y*_UVAnimY;
				o.uv1 = (v.texcoord+ fixed2(t1, t2))*_Scale;
				return o;
			}

			fixed4 frag(v2f i) : Color {
                fixed4 tex2 = tex2D(_IllumMap, i.uv1);
                fixed4 col = tex2D(_MainTex, i.uv);
                col.rgb = tex2.rgb*_Mul + col.rgb;
				return col;
			}
			
			ENDCG
		}
		
	} 
	FallBack "Diffuse"
}
